package com.fingard.dsp.bank.reqrespobj.unifiedorder;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.text.StringHelper;
import com.fingard.xml.XmlTextWriter;

import java.util.HashMap;

public class RetAtsQueryOrder extends RetAtsBase {
	public String respCode;
	public String respInfo;

	/** 商户订单号 */
	public String rdSeq;
	/** 商户号 */
	public String ourBankAccount;

	/** 第三方支付渠道生成的订单号或流水号 */
	public String outTransID;
	public String openId;
	public String oppAct;
	public String oppBank;
	public String transState;
	public String payInfoCode;
	public String transAmt;
	
	/** 支付方式(02-微信,03-支付宝) */
	public String payType;

	public HashMap<String, String> getRetAtsHashMap() {
		HashMap<String, String> retHash = new HashMap<String, String>();
		
		if (StringHelper.hasAnyChar(respCode)) {
			retHash.put("RespCode", respCode);
		}
		if (StringHelper.hasAnyChar(respInfo)) {
			retHash.put("RespInfo", respInfo);
		}
		if (StringHelper.hasAnyChar(rdSeq)) {
			retHash.put("RdSeq", rdSeq);
		}
		if (StringHelper.hasAnyChar(oppBank)) {
			retHash.put("OppBank", oppBank);
		}
		if (StringHelper.hasAnyChar(transState)) {
			retHash.put("TransState", transState);
		}
		if (StringHelper.hasAnyChar(payInfoCode)) {
			retHash.put("PayInfoCode", payInfoCode);
		}
		if (StringHelper.hasAnyChar(outTransID)) {
			retHash.put("OutTransID", outTransID);
		}
		if (StringHelper.hasAnyChar(openId)) {
			retHash.put("OpenId", openId);
		}
		if (StringHelper.hasAnyChar(oppAct)) {
			retHash.put("OppBankAccount", oppAct);
		}
		if (StringHelper.hasAnyChar(payType)) {
			retHash.put("TradeType", payType);
		}
		if (StringHelper.hasAnyChar(transAmt)) {
			retHash.put("TransAmt", transAmt);
		}
		if (StringHelper.hasAnyChar(ourBankAccount)) {
			retHash.put("OurBankAccount", ourBankAccount);
		}

		return retHash;
	}
	
	public void writeRetAtsXml(ReqRespHeader p_header){		
		retHeader = p_header;
		retXmlWriter = new XmlTextWriter();
		
		writeStart();
		
		retXmlWriter.writeStartElement("DetailRecord");
		if (StringHelper.hasAnyChar(respCode)) {
			retXmlWriter.writeElementString("RespCode", respCode);
		}
		if (StringHelper.hasAnyChar(respInfo)) {
			retXmlWriter.writeElementString("RespInfo", respInfo);
		}
		if (StringHelper.hasAnyChar(rdSeq)) {
			retXmlWriter.writeElementString("RdSeq", rdSeq);
		}
		if (StringHelper.hasAnyChar(oppBank)) {
			retXmlWriter.writeElementString("OppBank", oppBank);
		}
		if (StringHelper.hasAnyChar(transState)) {
			retXmlWriter.writeElementString("TransState", transState);
		}
		if (StringHelper.hasAnyChar(payInfoCode)) {
			retXmlWriter.writeElementString("PayInfoCode", payInfoCode);
		}
		if (StringHelper.hasAnyChar(outTransID)) {
			retXmlWriter.writeElementString("OutTransID", outTransID);
		}
		if (StringHelper.hasAnyChar(openId)) {
			retXmlWriter.writeElementString("OpenId", openId);
		}
		if (StringHelper.hasAnyChar(oppAct)) {
			retXmlWriter.writeElementString("OppBankAccount", oppAct);
		}
		if (StringHelper.hasAnyChar(payType)) {
			retXmlWriter.writeElementString("TradeType", payType);
		}
		if (StringHelper.hasAnyChar(transAmt)) {
			retXmlWriter.writeElementString("TransAmt", transAmt);
		}
		if (StringHelper.hasAnyChar(ourBankAccount)) {
			retXmlWriter.writeElementString("OurBankAccount", ourBankAccount);
		}

		retXmlWriter.writeEndElement();
		
		writeEnd();
	}
}
